// 引入vue-router
import { createRouter, createWebHistory } from "vue-router";
// 定义routes路由数组，多个路由需要使用,号进行分隔
const routes = [
  {
    path: "/",
    name: "Home",
    component: () => {
      return import("../home.vue");
    },
    meta: {
      keepalive: true,
    },
  },
  {
    path: "/preView",
    name: "PreView",
    component: () => {
      return import("../preView.vue");
    },
    meta: {
      keepalive: false,
    },
  },
  // {
  //   path: "/",
  //   name: "PreView",
  //   component: () => {
  //     return import("../preView.vue");
  //   },
  //   meta: {
  //     keepalive: true,
  //   },
  // }
];

// 实例化VueRouter并将routes添加进去
const router = createRouter({
  //history为router模式
  history: createWebHistory(),
  // ES6简写，等于routes：routes
  routes,
});

// 抛出这个这个实例对象方便外部读取以及访问
export default router;
